import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
    {
        path: '/login',
        component: () => import('@/views/login/login.vue'),
    },
    {
        path: '/reg',
        component: () => import('@/views/login/reg.vue'),
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('@/layouts/default.vue'),
        redirect: '/home/dashboard',
        children: [
            {
                name: 'dashboard',
                path: 'dashboard',
                component: () => import('@/views/dashboard/index.vue'),
                meta: {
                    icon: 'fas fa-home',
                },
            },
            {
                name: 'users',
                path: 'users',
                component: () => import('@/views/user/index.vue'),
                meta: {
                    icon: 'fas fa-user',
                },
            },
            {
                name: 'roles',
                path: 'roles',
                component: () => import('@/views/roles/index.vue'),
                meta: {
                    icon: 'fas fa-tools',
                },
            },
            {
                name: 'menus',
                path: 'menus',
                component: () => import('@/views/menus/index.vue'),
                meta: {
                    icon: 'fas fa-bars',
                },
            },
        ]
    }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export function setupRouter(app) {
    app.use(router)
}